<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
	<th:block th:include="include :: header('khz dept list')" />
	<th:block th:include="include :: layout-latest-css" />
	<th:block th:include="include :: ztree-css" />
</head>
<body class="gray-bg">
	<div class="container-div">
		<div class="row">
			<div class="col-sm-12 search-collapse">
				<form id="form">
					<input type="hidden" id="pageFlag" name="pageFlag" th:value="${khzDept.pageFlag}"/>
					<div class="select-list">
						<ul>
							<li>
								考核组：
								<select name="khz" id="khz" th:with="dicts=${@dict.getType('rate_khz')}">
									<option value="">--请选择--</option>
									<option th:each="dict : ${dicts}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"
										th:selected="${khzDept.khz == dict.dictValue}"></option>
								</select>
							</li>
							<li>
								主管科室：
								<select name="manager" id="manager" th:with="dicts=${@dict.getType('sys_yes_no')}">
									<option value="">--请选择--</option>
									<option th:each="dict : ${dicts}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"
										th:selected="${khzDept.manager == dict.dictValue}"></option>
								</select>
							</li>
							<li>
								<a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
								<a style="margin-left:20px;" class="btn btn-danger btn-rounded btn-sm" onclick="add()"><i class="fa fa-plus"></i> 新增</a>
							</li>
						</ul>
					</div>
				</form>
			</div>
			<div class="col-sm-12 select-table table-striped">
				<table id="bootstrap-table"></table>
			</div>
		</div>
	</div>
	
	<th:block th:include="include :: footer" />
	<th:block th:include="include :: layout-latest-js" />
	<script th:inline="javascript">
		var prefix = ctx + "rate/khzDept";
		var khzDict = [[${@dict.getType('rate_khz')}]];
		var yesNoDict = [[${@dict.getType('sys_yes_no')}]];
		var pageFlag = [[${khzDept.pageFlag}]];

		$(function() {
			list();
		});

		function list() {
			var options = {
				url: prefix + "/list",
				modalName: "khzDept",
				columns: [{
					field: 'id',
					visible: false
				},
				{
					field: 'khz',
					align: 'center',
					title: '考核组',
					formatter: function(value, row, index) {
						return $.table.selectDictLabel(khzDict, value);
					}
				},
				{
					field: 'dept.deptName',
					align: 'center',
					title: '成员科室'
				},
				{
					field: 'manager',
					align: 'center',
					title: '主管科室',
					formatter: function(value, row, index) {
						return $.table.selectDictLabel(yesNoDict, value);
					}
				},
				{
					field: 'ordr',
					align: 'center',
					title: '顺序'
				},
				{
					field: 'remark',
					align: 'center',
					title: '备注'
				},
				{
					title: '操作',
					align: 'center',
					width: '30%',
					formatter: function(value, row, index) {
						var actions = [];
						actions.push('<a class="btn btn-success btn-xs" href="javascript:void(0)" onclick="edit(\'' + row.id + '\')"><i class="fa fa-edit"></i>编辑</a> ');
						actions.push('<a class="btn btn-success btn-xs" href="javascript:void(0)" onclick="remove1(\'' + row.id + '\')"><i class="fa fa-times"></i>删除</a> ');
						return actions.join('');
					}
				}]
			};
			$.table.init(options);
		}
		
		function add() {
			$.modal.open("新增",
					prefix + "/add?pageFlag=ADD");
		}
		function edit(id) {
			$.modal.open("修改",
					prefix + "/edit?pageFlag=EDIT&id=" + id);
		}
		function remove1(id) {
			$.modal.confirm("确认要删除该条记录吗?", function() {
				var url = prefix + "/delete/" + id;
				var data = {"timestamp": new Date().getTime()};
				$.operate.submit(url, "post", "json", data);
			});
		}
	</script>
</body>
</html>